package fun._6742.model.dataobject;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import fun._6742.request.CreateProductRequest;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author LiuQ
 * @since 2022-09-21
 */
@Data
@Builder
@EqualsAndHashCode(callSuper = false)
@TableName("product")
@AllArgsConstructor
@NoArgsConstructor
public class ProductDO implements Serializable {

    private static final long serialVersionUID = 1L;

      @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 标题
     */
    private String title;

    /**
     * 封面图
     */
    private String coverImg;

    /**
     * 详情
     */
    private String detail;

    /**
     * 老价格
     */
    private BigDecimal oldPrice;

    /**
     * 新价格
     */
    private BigDecimal price;

    /**
     * 库存
     */
    private Integer stock;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 锁定库存
     */
    private Integer lockStock;

    /**
     * 类别
     */
    private Long category;

    /**
     * 品牌
     */
    private String brand;


    public ProductDO(CreateProductRequest createProductRequest) {
        BeanUtil.copyProperties(createProductRequest, this);
        this.createTime = new Date();
    }
}
